<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
  die('Could not connect: ' . mysql_error());
}
if(isset($_POST["simpan"]))
{
$pekerjaan = $_POST['pekerjaan'];
$nomor = $_POST['nomor'];
$jenis_pekerjaan = $_POST['jenis'];
if($jenis_pekerjaan=1){
	$score = 75;
}	elseif($jenis_pekerjaan=2){
	$score = 80;
}	else{
	$score = 85;
}
$nip = $_POST['pegawai'];
$due_pekerjaan = $_POST['tanggal'];
$detil_pekerjaan = $_POST['keterangan'];

$lokasi_file = $_FILES['nama_file']['tmp_name'];
$nama_file = $_FILES['nama_file']['name'];
$tipe_file = $_FILES['nama_file']['type'];
$ukuran_file = $_FILES['nama_file']['size'];

	$nama_baru = preg_replace("/\s+/", "_", $nip."_profile.zip");
	$direktori = "../../img/profile/$nama_baru";
	$MAX_FILE_SIZE = 10000000; //10MB
	move_uploaded_file($lokasi_file, $direktori);

$sql = "INSERT INTO pekerjaan(NAMA_PEKERJAAN,NOMOR_SURAT,ID_JENIS,NIP,DUE_PEKERJAAN,DETIL_PEKERJAAN,SCORE)
VALUES ('$pekerjaan','$nomor','$jenis_pekerjaan','$nip','$due_pekerjaan','$detil_pekerjaan','$score')";

mysql_select_db('mpd');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
  die('Could not enter data: ' . mysql_error());
}
}
header('location:../view/index.php');
//echo "Entered data successfully\n";
mysql_close($conn);
?>